/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 排行分段数据
	/// module : structs_internal
	/// </summary>
	public class RankSubsectionItemPOD : IPOD 
    {
        public readonly static Func<RankSubsectionItemPOD> FACTORY = () => new RankSubsectionItemPOD();
		public static Func<RankSubsectionItemPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public long score;
		/// <summary>
        /// 
        /// </summary>
		public int percentRank;
		/// <summary>
        /// 
        /// </summary>
        private List<long> m_pids;
		
		
        public List<long> pids
        {
            get
            {
                if(m_pids == null)
                {
                    m_pids = new();
                }
                return m_pids;
            }
            private set => m_pids = value;
        }
        public List<long> unsafe_pids
        {
        	get => m_pids;
        	set => m_pids = value;
        }
		
		/*-- constructors --*/
		public RankSubsectionItemPOD() {}
		public RankSubsectionItemPOD(long score, int percentRank, List<long> pids) {
			this.score = score;
			this.percentRank = percentRank;
			this.m_pids = pids;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_long(score);
            _out.Write_int(percentRank);
            _out.Write_list_long(m_pids); 
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            score = _in.Read_long();
            if(!_in.HasRemaining()) return;
            percentRank = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_pids = _in.Read_list_long();
        }
		
		public RankSubsectionItemPOD Clone() {
            RankSubsectionItemPOD o = DynamicFactory();
            o.score = score;
            o.percentRank = percentRank;
            if (m_pids != null) {
                o.m_pids = new (m_pids);
            }
            return o;
        }
        
        public void Clear() {
            score = default;
            percentRank = default;
            m_pids = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "RankSubsectionItemPOD [";
			str += "score=";
			str += score;
			str += ", percentRank=";
			str += percentRank;
			str += ", pids=";
			str += m_pids.ToString<long>();
			str += "]";
			return str;
		}
		
	}
}